/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrgs.jsopa;

/**
 * Our programmable timer. Need to implement its programmability. I guess it is
 * one-time programmable only. Resetting it once running might be difficult to
 * implement.
 */
class Timer extends Thread {

    private IntController intCn;

    public Timer(IntController i) {
        intCn = i;
    }

    @Override
    public void run() {
        while (Main.isSystemOn()) {
            try {
                sleep(Main.SLEEP_TIME * 10); // was half second
                // Here goes the code (2 lines) that generates an interrupt
                intCn.P();
                intCn.set(2);
            } catch (InterruptedException e) {
            }
            Main.print("timer");
        }
        Main.print("Timer is shutting down");
    }
}